package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Report;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Autor JiangYunTian
 * @Date 2022/11/11
 * @Function 测灵魂Mapper接口,报告
 */
public interface ReportMapper extends BaseMapper<Report> {

    //查找分数相近的用户
    @Select("Select distinct user_id from tb_report where  survey_id = #{surveyId} and score between #{score}-10 and #{score}+10 ")
    List<Long> findSimilarYou(Long surveyId, Integer score);

    //根据用id查询最新的报告
    @Select("Select * from tb_report where user_id = #{userId} and survey_id = #{surveyId} order by created desc limit 0,1")
    Report findReportByUserId(Long userId,Long surveyId);
}
